package top.ckxgzxa.newscms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.ckxgzxa.newscms.entity.News;
import top.ckxgzxa.newscms.mapper.NewsMapper;
import top.ckxgzxa.newscms.service.NewsService;

import java.util.List;

/**
 * @author 赵希奥
 * @date 2022/4/29 23:18
 * @gitHub https://github.com/CKXGZXA
 * @gitee https://gitee.com/ckxgzxa
 * @description:
 */

@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {

    @Autowired
    private NewsMapper newsMapper;

    @Override
    public List<News> listOrderByCreateTimeDesc() {
        LambdaQueryWrapper<News> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(News::getCreateTime);
        return newsMapper.selectList(queryWrapper);
    }
}
